package com.yyz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yyz.domain.DishFlavor;
import com.yyz.mapper.DishFlavorMapper;
import com.yyz.service.DishFlavorService;
import com.yyz.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yyz
 * @create 2023-07-21 15:42
 */
@Service
public class DishFlavorServiceImpl implements DishFlavorService {
    @Autowired
    private DishFlavorMapper dishFlavorMapper;

    /**
     * 添加口味
     * @param list
     */
    @Override
    public void insert(List<DishFlavor> list) {
        for (DishFlavor dishFlavor : list) {
            dishFlavorMapper.insert(dishFlavor);
        }
    }

    /**
     * 根据dish_id查询
     * @param id
     * @return
     */
    @Override
    public List<DishFlavor> selectById(Long id) {
        LambdaQueryWrapper<DishFlavor> lqw = new LambdaQueryWrapper<>();
        lqw.eq(DishFlavor::getDishId,id);

        List<DishFlavor> dishFlavors = dishFlavorMapper.selectList(lqw);

        return dishFlavors;
    }

    /**
     * 修改口味
     * @param list
     */
    @Override
    public void update(List<DishFlavor> list) {

        for (DishFlavor dishFlavor : list) {
            dishFlavorMapper.insert(dishFlavor);
        }
    }

    /**
     * 根据条件删除
     * @param lqw
     */
    @Override
    public void delete(LambdaQueryWrapper<DishFlavor> lqw) {
        dishFlavorMapper.delete(lqw);
    }

    /**
     * 根据条件查询
     * @param dlqw
     */
    @Override
    public List<DishFlavor> selectList(LambdaQueryWrapper<DishFlavor> dlqw) {
        List<DishFlavor> dishFlavors = dishFlavorMapper.selectList(dlqw);
        return dishFlavors;
    }
}
